package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	file, err := os.Open("../file/20211029.vim")
	if err != nil {
		fmt.Println("open file faild,err=", err)
		return
	}

	//创建一个有缓冲区的reader
	reader := bufio.NewReader(file)
	for {
		buf, err := reader.ReadBytes('\n')

		if err != nil && err != io.EOF {
			fmt.Println("read file faild,err=", err)
			return
		} else if err == io.EOF {
			fmt.Println("文件读完了")
			return
		}
		fmt.Println(string(buf))
	}
}
